// 上辈子作恶多端，这辈子开发后端
/*let myFirstJob = "Programmer";
let myCurrenJob = "Teacher";

let currenDate = new Date();

console.log(myFirstJob, myCurrenJob);
console.log(currenDate);*/

/*
let a = 30;
let b = "jason";
let c = false;
let d = null;
console.log(typeof a);
console.log(typeof b);
console.log(typeof c);
console.log(typeof d); // JS设计遗留的缺陷 */

/*
let num1 = "1";
let num2 = 2;
let num3 = 2 ** 3; // 表示2的三次方 就是8
const now = 2043;
let mathNumber = 30;

mathNumber++;
mathNumber *= 2;

console.log(mathNumber);
console.log(now - 2001 > now - 2000);
console.log(num3);
console.log(+num1 + num2);*/

/*
const now = 2037;
const ageJonas = now - 1991;
const ageSarah = now - 2018;

console.log(now - ageJonas > now - ageSarah);

let x, y;
x = y = 25 - 15 - 5;
console.log(x, y);

const averageAge = (ageJonas + ageSarah) / 2; // 要加括号,除号优先级大于加号
console.log(ageJonas, ageSarah, averageAge);*/

// Code Challenge #1
/*const markMass = 78;
const markHeight = 1.69;
const markBMI = markMass / markHeight ** 2;
const johnMass = 92;
const johnHeight = 1.95;
const johnBMI = johnMass / johnHeight ** 2;

const markHigherBMI = markBMI > johnBMI;

console.log(markHigherBMI);*/

/*
const firstName = "jason";
const year = 2013;
const job = "teacher";
const birthYear = "191";

const jonas =
  "I'm " + firstName + ", a " + (year - birthYear) + " year old " + job + "!";
console.log(jonas);

const jonasNew = `I'm ${firstName}, a ${year - birthYear} yaer old ${job}`;
console.log(jonasNew);

console.log(`Just a regular string...`);

console.log(
  "String with \n\
multiple \n\
line"
);
console.log(`String multiple lines`);*/

/*
const birthYear = 2012;
let century;
if (birthYear <= 2000) century = 20;
else century = 21;

console.log(`${century}世纪`);*/

// type conversion
/*
const inputYear = "1991";
console.log(Number(inputYear), inputYear);
console.log(Number(inputYear) + 18);

console.log(Number("Jonas"));
console.log(typeof NaN);

console.log(String(23), 23);

// type coercion,字符串与字符串做运算会转换成Number类型，但是字符串和数字做运算，就会转为字符串类型拼接
console.log("I am " + 23 + " years old");
console.log("23" - "10" - 3);
console.log("23" / "2");

let n = "1" + 1;
n = n - 1;
console.log(n);*/

/*
console.log(Boolean(0)); // false
console.log(Boolean(undefined)); // false
console.log(Boolean("jason")); // true
console.log(Boolean("")); // false
console.log(Boolean({})); //  true

let height;
if (height) console.log("Yay height is defined");
else console.log ("Height is UNDEFINED");*/

/*
console.log("18" === 18); // 值和类型都要相等
console.log("20" == 20); // 值相等即可

// const favourite = Number(prompt("What's you like favourite number?"));
// console.log(favourite);

const hasDriversLicense = true;
const hasGoodVision = true;

console.log(hasDriversLicense && hasGoodVision);
console.log(hasDriversLicense || hasGoodVision);
console.log(!hasDriversLicense);

const isTired = true;
if (hasDriversLicense && hasGoodVision && !isTired)
  console.log("Sarah is able to drive!");
else console.log("Someone else should drive");*/

// Code Challenge #
/*
const scoreDolphins = Math.floor((97 + 112 + 80) / 3); //向下取整
const scoreKoalas = Math.floor((109 + 95 + 150) / 3);
console.log(scoreDolphins, scoreKoalas);

if (scoreDolphins > scoreKoalas && scoreDolphins >= 100)
  console.log("Dolhins win the trophy! 👍 ");
else if (scoreKoalas > scoreDolphins && scoreKoalas >= 100)
  console.log("Koalas win the trophy! ");
else if (
  scoreDolphins === scoreKoalas &&
  scoreDolphins >= 100 &&
  scoreKoalas >= 100
)
  console.log("Both win the trophy!");
else console.log("No one wins the trophy!😹");

console.log(this);*/

/*
const day = "monday";
switch (day) {
  case "monday":
    console.log("Plan course structure");
    console.log("Go to coding meetup");
    break;
  case "tuesday":
    console.log("Prepare theory videos");
    break;
  case "wednesday":
  case "thursday":
    console.log("Write code examples");
    break;
  case "saturday":
  case "sunday":
    console.log("Enjoy the weekend :D");
    break;
  default:
    console.log("Not a valid day!");
}*/

// 表达式和语句diff
// 表达式是有值的，而语句是没有的比如
const name = "jason is very good"; // 这句话是语句，就是正常的字符串语句
const me = "jason";
console.log(`I'm ${2031 - 1999} years old, ${me}`);

const age = 23;
const drink = age >= 18 ? "wine 🍷" : "water💧";
console.log(drink);
console.log(`I like to drink ${age >= 38 ? "wine 🍷" : "water 💧"}`);

const bill = 40;
const tip = (50 <= bill && bill <= 300 ? 0.15 : 0.2) * bill;
console.log(
  `The bill was ${bill}, the tip was ${tip} and the total value ${bill + tip}`
);
